package minh.bac.wcbrazil2014.broadcastreceiver;

import minh.bac.wcbrazil2014.HomeScreen;
import minh.bac.wcbrazil2014.WCTAG;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;

public class AlarmService extends Service{

	NotificationManager notificationManager;
	String detail;
	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		// TODO Auto-generated method stub
		Bundle bundle = intent.getExtras();
		detail = bundle.getString(WCTAG.TAG_WAKE_DETAIL_NOTIFI);
		notificationManager = (NotificationManager) this.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
		//
		Intent intents = new Intent(this.getApplicationContext(), HomeScreen.class);
		PendingIntent pendingIntentNotidfi = PendingIntent.getActivity(this.getApplicationContext(), 0, intents, PendingIntent.FLAG_UPDATE_CURRENT);
		Notification notificationCompat = new NotificationCompat.Builder(getApplicationContext())
																		.setContentTitle("Fifa World Cup 2014")
																		.setContentText(detail)
																		.setContentIntent(pendingIntentNotidfi)
																		.setSmallIcon(minh.bac.wcbrazil2014.R.drawable.ic_launcher)
																		.setDefaults(Notification.DEFAULT_SOUND)
																		.setAutoCancel(true)
																		.build();
		notificationManager.notify(0, notificationCompat);
		return super.onStartCommand(intent, flags, startId);
	}

}
